<blocks app="Snap! 5.1, http://snap.berkeley.edu" version="1"><block-definition s="Hummingbird %&apos;sensor&apos; %&apos;port&apos;" type="reporter" category="sensing"><header></header><code></code><translations></translations><inputs><input type="%txt" readonly="true">Light<options>Distance (cm)&#xD;Dial&#xD;Light&#xD;Sound&#xD;Other (V)</options></input><input type="%n" readonly="true">1<options>1&#xD;2&#xD;3</options></input></inputs><script><block s="doDeclareVariables"><list><l>value</l></list></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Other (V)</l></block><script><block s="doSetVar"><l>sensor</l><l>Other</l></block></script></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Distance (cm)</l></block><script><block s="doSetVar"><l>sensor</l><l>Distance</l></block></script></block><block s="doSetVar"><l>value</l><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/in/</l><block var="sensor"/><l>/</l><block var="port"/></list></block></block></block><block s="doIfElse"><block s="reportNot"><block s="reportEquals"><block var="value"/><l>Not Connected</l></block></block><script><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Distance</l></block><script><block s="doReport"><block s="reportRound"><block s="reportProduct"><l>1.17</l><block var="value"/></block></block><comment w="90" collapsed="false">117/100 Scaling factor</comment></block></script></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Other</l></block><script><block s="doReport"><block s="reportQuotient"><block s="reportRound"><block s="reportProduct"><block s="reportProduct"><l>0.01294</l><block var="value"/></block><l>100</l></block></block><l>100</l></block><comment w="102" collapsed="false">3.3/255 scale factor</comment></block></script></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Sound</l><comment w="155" collapsed="true">If connected, adjust sound level</comment></block><script><block s="doReport"><block s="reportRound"><block s="reportProduct"><l>0.784</l><block var="value"/><comment w="140" collapsed="false">200/255 Scaling factor</comment></block></block></block></script></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Light</l></block><script><block s="doReport"><block s="reportRound"><block s="reportProduct"><l>0.392</l><block var="value"/><comment w="140" collapsed="false">100/255 Scaling factor</comment></block></block></block></script></block><block s="doIf"><block s="reportEquals"><block var="sensor"/><l>Dial</l></block><script><block s="doReport"><block s="reportRound"><block s="reportProduct"><l>0.435</l><block var="value"/><comment w="140" collapsed="false">100/230 Scaling factor</comment></block></block></block></script></block></script><script><block s="doReport"><l>Not Connected</l></block></script></block></script></block-definition><block-definition s="Hummingbird Play Note %&apos;note&apos; for %&apos;beats&apos; beats" type="command" category="sound"><header></header><code></code><translations>ko:Hummingbird _ 번 음을 _ 박자로 연주하기&#xD;de:Hummingbird Spiele Note _ für _ Schläge&#xD;pt:Hummingbird Toque Notas _ por _ Batidas&#xD;fr:Hummingbird Jouer la note _ pour _ battement(s)&#xD;nl:Hummingbird Speel Noot _ voor _ Beats&#xD;zh_CN:Hummingbird 演奏 音阶 _ 于 _ 拍&#xD;zh_TW:Hummingbird 演奏 音階 _ 於 _ 拍&#xD;ar:Hummingbird تشغيل الموسيقى  _ _&#xD;dk:Hummingbird Spil tone _ i _ slag&#xD;he:Hummingbird נגן תו   _  במשך  _   פעימות&#xD;es:Hummingbird Emitir un sonido _ por _ pulsos&#xD;ca:Hummingbird Toca nota _ durant _ temps&#xD;fi:Hummingbird Soita sävel _  _ iskun ajan&#xD;sv:Hummingbird Spela not _ _&#xD;</translations><inputs><input type="%n">60</input><input type="%n">0.5</input></inputs><script><block s="doIf"><block s="reportGreaterThan"><block var="note"/><l>135</l></block><script><block s="doSetVar"><l>note</l><l>135</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><l>32</l><block var="note"/></block><script><block s="doSetVar"><l>note</l><l>32</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="beats"/><l>16</l></block><script><block s="doSetVar"><l>beats</l><l>16</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><l>0</l><block var="beats"/></block><script><block s="doSetVar"><l>beats</l><l>0</l></block></script></block><block s="doSetVar"><l>beats</l><block s="reportRound"><block s="reportProduct"><block s="reportQuotient"><l>60000</l><block s="getTempo"></block></block><block var="beats"/></block><comment w="242" collapsed="false">BPM = tempo&#xD;60 * 1000/BPM = BPMS  beats per millisecond&#xD;beats = Duration in ms  = BPMS * number of beats</comment></block></block><block s="doRun"><block s="reifyReporter"><autolambda><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/playnote/</l><block var="note"/><l>/</l><block var="beats"/></list></block></block></autolambda><list></list></block><list></list></block><block s="doWait"><block s="reportQuotient"><block var="beats"/><l>1000</l></block><comment w="205" collapsed="false">block for number of seconds</comment></block></script></block-definition><block-definition s="micro:bit %&apos;device&apos; %&apos;dim&apos;" type="reporter" category="sensing"><header></header><code></code><translations></translations><inputs><input type="%s" readonly="true">Accelerometer (m/s²)<options>Accelerometer (m/s²)&#xD;Magnetometer (µT)</options></input><input type="%txt" readonly="true">X<options>X&#xD;Y&#xD;Z</options></input></inputs><script><block s="doIf"><block s="reportEquals"><block var="device"/><l>Accelerometer (m/s²)</l></block><script><block s="doSetVar"><l>device</l><l>Accelerometer</l></block></script></block><block s="doIf"><block s="reportEquals"><block var="device"/><l>Magnetometer (µT)</l></block><script><block s="doSetVar"><l>device</l><l>Magnetometer</l></block></script></block><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/in/</l><block var="device"/><l>/</l><block var="dim"/></list></block></block></block></script></block-definition><block-definition s="micro:bit Button %&apos;button&apos;" type="predicate" category="sensing"><header></header><code></code><translations>ko:micro:bit 버튼 _&#xD;de:micro:bit Knopf _&#xD;pt:micro:bit Tecla _&#xD;fr:micro:bit Bouton _&#xD;nl:micro:bit Knop _&#xD;zh_CN:micro:bit 按钮 _&#xD;zh_TW:micro:bit 按鈕 _&#xD;ar:micro:bit زر _&#xD;dk:micro:bit Knap _&#xD;he:micro:bit לחצן  _&#xD;es:micro:bit Pulsador _&#xD;ca:micro:bit Botó _&#xD;fi:micro:bit Painike _&#xD;sv:micro:bit Knapp _&#xD;</translations><inputs><input type="%txt" readonly="true">A<options>A&#xD;B</options></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/in/button/</l><block var="button"/></list></block></block><l>true</l></block><script><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definition s="micro:bit Compass" type="reporter" category="sensing"><header></header><code></code><translations>ko:micro:bit 나침반 센서&#xD;de:micro:bit Kompass&#xD;pt:micro:bit Bússola&#xD;fr:micro:bit Compas&#xD;nl:micro:bit Kompas&#xD;zh_CN:micro:bit 指南针&#xD;zh_TW:micro:bit 指南針&#xD;ar:micro:bit بوصلة&#xD;dk:micro:bit Kompas&#xD;he:micro:bit מצפן&#xD;es:micro:bit Brujula&#xD;ca:micro:bit Brúixola&#xD;fi:micro:bit Kompassi&#xD;sv:micro:bit Kompass&#xD;</translations><inputs></inputs><script><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/in/</l><l>Compass</l></list></block></block></block></script></block-definition><block-definition s="micro:bit %&apos;dim&apos;" type="predicate" category="sensing"><header></header><code></code><translations></translations><inputs><input type="%txt" readonly="true">Screen Up<options>Screen Up&#xD;Screen Down&#xD;Tilt Left&#xD;Tilt Right&#xD;Logo Up&#xD;Logo Down&#xD;Shake</options></input></inputs><script><block s="doIfElse"><block s="reportEquals"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/in/orientation/</l><block var="dim"/></list></block></block><l>true</l></block><script><block s="doReport"><block s="reportBoolean"><l><bool>true</bool></l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definition s="stop all" type="command" category="control"><header></header><code></code><translations>ko:모두 멈추기&#xD;de:stoppe alles&#xD;pt:pare todos&#xD;fr:stop tout&#xD;nl:stop alle&#xD;zh_CN:停止 全部&#xD;zh_TW:停止 全部&#xD;ar:توقف الكل&#xD;dk:stop alle&#xD;he:להפסיק הכל&#xD;es:detener todo&#xD;ca:atura tot&#xD;fi:pysäytä kaikki&#xD;sv:stop allt&#xD;</translations><inputs></inputs><script><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/stopall</l></list></block></block></block></script></block-definition><block-definition s="Hummingbird Position Servo %&apos;port&apos; %&apos;position&apos; °" type="command" category="motion"><header></header><code></code><translations>ko:Hummingbird 위치 제어 서보 _ _ °&#xD;de:Hummingbird Position Servo _ _ °&#xD;pt:Hummingbird Posição do Servo _ _ °&#xD;fr:Hummingbird Position Servo _ _ °&#xD;nl:Hummingbird Positie-Servo _ _ °&#xD;zh_CN:Hummingbird 位置伺服 _ _ °&#xD;zh_TW:Hummingbird 位置伺服 _ _ °&#xD;ar:Hummingbird موقف محرك سيرفو المؤازر  _ _&#xD;dk:Hummingbird Positionsservo _ _ °&#xD;he:Hummingbird סרוו כיוון     _ _&#xD;es:Hummingbird Servo de posicion _ _ °&#xD;ca:Hummingbird Servo posicional _ _ °&#xD;fi:Hummingbird Asentoservo _ _ °&#xD;sv:Hummingbird Positionsservo _ _ °&#xD;</translations><inputs><input type="%n" readonly="true">1<options>1&#xD;2&#xD;3&#xD;4</options></input><input type="%n">90</input></inputs><script><block s="doIf"><block s="reportLessThan"><block var="position"/><l>0</l></block><script><block s="doSetVar"><l>position</l><l>0</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="position"/><l>180</l></block><script><block s="doSetVar"><l>position</l><l>180</l></block></script></block><block s="doSetVar"><l>position</l><block s="reportRound"><block s="reportProduct"><block var="position"/><l>1.41</l></block></block><comment w="228" collapsed="false">254/180 Scaling Factor</comment></block><block s="doRun"><block s="reportJSFunction"><list><l>portnum</l><l>position</l></list><l>var realPort = portnum-1;&#xD;////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.servos === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.servos = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        setServoAngle: function (port, angle) {&#xD;            function callback() {&#xD;                if (window.birdbrain.servos[port] === angle) {&#xD;                    delete window.birdbrain.servos[port];&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.servos.setServoAngle(port, window.birdbrain.servos[port]);&#xD;                }&#xD;            }&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var actualPort = port+1;         &#xD;            var thisURL = "http://127.0.0.1:30061/hummingbird/out/servo/" + actualPort + "/" + angle;&#xD;            //console.log("thisURL: " + thisURL);&#xD;            xhr.open("GET", thisURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);          &#xD;            &#xD;        }&#xD;    };&#xD;}&#xD;&#xD;//var realAngle = Math.floor(ang*1.25);&#xD;&#xD;//realAngle = Math.max(Math.min(realAngle,225.0),0.0);&#xD;&#xD;if (window.birdbrain.servos[realPort] === undefined) {&#xD;    window.birdbrain.servos.setServoAngle(realPort, position);&#xD;}&#xD;&#xD;window.birdbrain.servos[realPort] = position;</l></block><list><block var="port"/><block var="position"/></list></block><block s="doWait"><l>0</l></block></script><scripts><script x="187.14285714285717" y="82.28571428571428"><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/servo/</l><l></l><l>/</l><l></l></list></block></block></block></script></scripts></block-definition><block-definition s="Hummingbird Rotation Servo %&apos;port&apos; %&apos;speed&apos; %" type="command" category="motion"><header></header><code></code><translations>ko:Hummingbird 회전속도 제어 서보 _ _ %&#xD;de:Hummingbird Drehung Servo _ _ %&#xD;pt:Hummingbird Rotação do Servo _ _ %&#xD;fr:Hummingbird Rotation Servo _ _ %&#xD;nl:Hummingbird Draai-Servo _ _ %&#xD;zh_CN:Hummingbird 旋转伺服 _ _ %&#xD;zh_TW:Hummingbird 旋轉伺服 _ _ %&#xD;ar:Hummingbird فتحة دوران المحرك المؤازر  _ _&#xD;dk:Hummingbird Rotationsservo _ _ %&#xD;he:Hummingbird סרוו סיבובים    _ _ %&#xD;es:Hummingbird Servo de rotacion _ _ %&#xD;ca:Hummingbird Servo rotacional _ _ %&#xD;fi:Hummingbird Kiertoservo _ _ %&#xD;sv:Hummingbird Rotationsservo _ _ %&#xD;</translations><inputs><input type="%n" readonly="true">1<options>1&#xD;2&#xD;3&#xD;4</options></input><input type="%n">0</input></inputs><script><block s="doIf"><block s="reportLessThan"><block var="speed"/><l>-100</l></block><script><block s="doSetVar"><l>speed</l><l>-100</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="speed"/><l>100</l></block><script><block s="doSetVar"><l>speed</l><l>100</l></block></script></block><block s="doIfElse"><block s="reportAnd"><block s="reportGreaterThan"><block var="speed"/><l>-10</l></block><block s="reportLessThan"><block var="speed"/><l>10</l></block></block><script><block s="doSetVar"><l>speed</l><l>255</l></block></script><script><block s="doSetVar"><l>speed</l><block s="reportRound"><block s="reportSum"><block s="reportQuotient"><block s="reportProduct"><block var="speed"/><l>23</l></block><l>100</l></block><l>122</l></block></block></block></script></block><block s="doRun"><block s="reportJSFunction"><list><l>portnum</l><l>speed</l></list><l>var realPort = portnum-1;&#xD;////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.rotationServos === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.rotationServos = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        setServoSpeed: function (port, speed) {&#xD;            function callback() {&#xD;                if (window.birdbrain.rotationServos[port] === speed) {&#xD;                    delete window.birdbrain.rotationServos[port];&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.rotationServos.setServoSpeed(port, window.birdbrain.rotationServos[port]);&#xD;                }&#xD;            }&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var actualPort = port+1;         &#xD;            var thisURL = "http://127.0.0.1:30061/hummingbird/out/rotation/" + actualPort + "/" + speed;&#xD;            //console.log("thisURL: " + thisURL);&#xD;            xhr.open("GET", thisURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);          &#xD;            &#xD;        }&#xD;    };&#xD;}&#xD;&#xD;if (window.birdbrain.rotationServos[realPort] === undefined) {&#xD;    window.birdbrain.rotationServos.setServoSpeed(realPort, speed);&#xD;}&#xD;&#xD;window.birdbrain.rotationServos[realPort] = speed;</l></block><list><block var="port"/><block var="speed"/></list></block></script></block-definition><block-definition s="Hummingbird LED %&apos;port&apos; %&apos;intensity&apos; %" type="command" category="looks"><header></header><code></code><translations>ko:Hummingbird LED _ _ %&#xD;de:Hummingbird LED _ _ %&#xD;pt:Hummingbird LED _ _ %&#xD;fr:Hummingbird LED _ _ %&#xD;nl:Hummingbird LED _ _ %&#xD;zh_CN:Hummingbird LED _ _ %&#xD;zh_TW:Hummingbird LED _ _ %&#xD;ar:Hummingbird ضوء _ _&#xD;dk:Hummingbird LED _ _ %&#xD;he:Hummingbird לד   % _ _&#xD;es:Hummingbird LED _ _ %&#xD;ca:Hummingbird LED _ _ %&#xD;fi:Hummingbird LED _ _ %&#xD;sv:Hummingbird LED _ _ %&#xD;</translations><inputs><input type="%n" readonly="true">1<options>1&#xD;2&#xD;3</options></input><input type="%n">0</input></inputs><script><block s="doIf"><block s="reportLessThan"><block var="intensity"/><l>0</l></block><script><block s="doSetVar"><l>intensity</l><l>0</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="intensity"/><l>100</l></block><script><block s="doSetVar"><l>intensity</l><l>100</l></block></script></block><block s="doRun"><block s="reportJSFunction"><list><l>portnum,intensitynum</l></list><l>//var hummingbirdAppID = "lfloofocohhfeeoohpokmljiinfmpenj";&#xD;var realPort = portnum-1;&#xD;////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.LEDs === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.LEDs = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        setLEDIntensity: function(port, intensity) {&#xD;            function callback() {&#xD;                if (window.birdbrain.LEDs[port] === intensity) {&#xD;                    delete window.birdbrain.LEDs[port];&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.LEDs.setLEDIntensity(port, window.birdbrain.LEDs[port]);&#xD;                }&#xD;            }&#xD;            /*&#xD;            var report = {&#xD;                message:"L".charCodeAt(0),&#xD;                port: port.toString().charCodeAt(0),&#xD;                intensity: intensity&#xD;            };&#xD;            chrome.runtime.sendMessage(hummingbirdAppID, report, callback);&#xD;            */&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var actualPort = port+1;&#xD;            var ledURL = "http://127.0.0.1:30061/hummingbird/out/led/" + actualPort + "/" + intensity;&#xD;            xhr.open("GET", ledURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);&#xD;&#xD;        }&#xD;    }&#xD;}&#xD;&#xD;var realIntensity = Math.floor(intensitynum*2.55);&#xD;&#xD;realIntensity = Math.max(Math.min(realIntensity,255.0),0.0);&#xD;&#xD;if (window.birdbrain.LEDs[realPort] === undefined) {&#xD;  window.birdbrain.LEDs.setLEDIntensity(realPort, realIntensity);&#xD;}&#xD;&#xD;window.birdbrain.LEDs[realPort] = realIntensity;</l></block><list><block var="port"/><block var="intensity"/></list></block><block s="doWait"><l>0</l></block></script><scripts><script x="396.42857142857144" y="46.57142857142853"><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/led/</l><block var="port"/><l>/</l><block var="intensity"/></list></block></block></block></script><script x="396.42857142857144" y="100.28571428571436"><block s="doSetVar"><l>intensity</l><block s="reportRound"><block s="reportProduct"><block var="intensity"/><l>2.55</l><comment w="90" collapsed="false">Scale factor 255/100</comment></block></block></block></script></scripts></block-definition><block-definition s="Hummingbird Tri-LED %&apos;port&apos; R %&apos;redLED&apos; % G %&apos;greenLED&apos; % B %&apos;blueLED&apos; %" type="command" category="looks"><header></header><code></code><translations>ko:Hummingbird 삼색 LED _ 빨강 _ % 초록 _ % 파랑 _ %&#xD;de:Hummingbird Dreifarben-LED _ R _ % G _ % B _ %&#xD;pt:Hummingbird LED Tricolor _ R _ % G _ % B _ %&#xD;fr:Hummingbird Tri-LED _ R _ % G _ % B _ %&#xD;nl:Hummingbird Tri-LED _ R _ % G _ % B _ %&#xD;zh_CN:Hummingbird 三色LED _ 红 _ % 绿 _ % 蓝 _ %&#xD;zh_TW:Hummingbird 三色LED _ 紅 _ % 綠 _ % 藍 _ %&#xD;ar:Hummingbird ضوء الصمام الثلاثي  _ _ _ _&#xD;dk:Hummingbird Tri-LED _ R _ % G _ % B _ %&#xD;he:Hummingbird לד שלושה צבעים       % _ R   _   %  G _  %   B  _&#xD;es:Hummingbird Led tricolor _ R _ % G _ % B _ %&#xD;ca:Hummingbird Tri-LED _ vermell _ % verd _ % blau _ %&#xD;fi:Hummingbird Tri-LED _ R _ % G _ % B _ %&#xD;sv:Hummingbird Tri-LED _ R _ % G _ % B _ %&#xD;</translations><inputs><input type="%n" readonly="true">1<options>1&#xD;2</options></input><input type="%n">0</input><input type="%n">0</input><input type="%n">0</input></inputs><script><block s="doIf"><block s="reportLessThan"><block var="redLED"/><l>0</l></block><script><block s="doSetVar"><l>redLED</l><l>0</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="redLED"/><l>100</l></block><script><block s="doSetVar"><l>redLED</l><l>100</l></block></script></block><block s="doIf"><block s="reportLessThan"><block var="greenLED"/><l>0</l></block><script><block s="doSetVar"><l>greenLED</l><l>0</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="greenLED"/><l>100</l></block><script><block s="doSetVar"><l>greenLED</l><l>100</l></block></script></block><block s="doIf"><block s="reportLessThan"><block var="blueLED"/><l>0</l></block><script><block s="doSetVar"><l>blueLED</l><l>0</l></block></script></block><block s="doIf"><block s="reportGreaterThan"><block var="blueLED"/><l>100</l></block><script><block s="doSetVar"><l>blueLED</l><l>100</l></block></script></block><block s="doRun"><block s="reportJSFunction"><list><l>portnum</l><l>rednum</l><l>greennum</l><l>bluenum</l></list><l>var realPort = portnum-1;&#xD;////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.triLEDs === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.triLEDs = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        setLEDIntensities: function(port, intensities) {&#xD;            function callback() {&#xD;                if (JSON.stringify(window.birdbrain.triLEDs[port]) === JSON.stringify(intensities)) {&#xD;                    delete window.birdbrain.triLEDs[port];&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.triLEDs.setLEDIntensities(port, window.birdbrain.triLEDs[port]);&#xD;                }&#xD;            }&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var actualPort = port+1;&#xD;            /*  Note RGB:&#xD;                red: intensities[0],&#xD;                green: intensities[1],&#xD;                blue: intensities[2]  &#xD;            */&#xD;            &#xD;            var thisURL = "http://127.0.0.1:30061/hummingbird/out/triled/" + actualPort + "/" + intensities[0] + "/" + intensities[1] + "/" + intensities[2];&#xD;            //console.log("thisURL: " + thisURL);&#xD;            xhr.open("GET", thisURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);&#xD;        }&#xD;    }&#xD;}&#xD;&#xD;var realIntensities = [rednum, greennum, bluenum].map(function(intensity) {&#xD;    return Math.floor(Math.max(Math.min(intensity*2.55, 255), 0));&#xD;});&#xD;&#xD;if (window.birdbrain.triLEDs[realPort] === undefined) {&#xD;    window.birdbrain.triLEDs.setLEDIntensities(realPort, realIntensities);&#xD;}&#xD;&#xD;window.birdbrain.triLEDs[realPort] = realIntensities;&#xD;</l></block><list><block var="port"/><block var="redLED"/><block var="greenLED"/><block var="blueLED"/></list></block><block s="doWait"><l>0</l></block></script><scripts><script x="251.42857142857144" y="108.85714285714293"><block s="doSetVar"><l>redLED</l><block s="reportRound"><block s="reportProduct"><block var="redLED"/><l>2.55</l><comment w="90" collapsed="false">Scale factor 255/100</comment></block></block></block><block s="doSetVar"><l>blueLED</l><block s="reportRound"><block s="reportProduct"><block var="blueLED"/><l>2.55</l><comment w="90" collapsed="false">Scale factor 255/100</comment></block></block></block><block s="doSetVar"><l>greenLED</l><block s="reportRound"><block s="reportProduct"><block var="greenLED"/><l>2.55</l><comment w="90" collapsed="false">Scale factor 255/100</comment></block></block></block><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/triled/</l><l></l><l>/</l><l></l><l>/</l><l></l><l>/</l><l></l></list></block></block></block></script></scripts></block-definition><block-definition s="micro:bit Print %&apos;string&apos;" type="command" category="looks"><header></header><code></code><translations>ko:micro:bit 출력 _&#xD;de:micro:bit Drucke _&#xD;pt:micro:bit Imprimir _&#xD;fr:micro:bit Imprimer _&#xD;nl:micro:bit Schrijf _&#xD;zh_CN:micro:bit 打印 _&#xD;zh_TW:micro:bit 打印 _&#xD;ar:micro:bit طباعة _&#xD;dk:micro:bit Vis _&#xD;he:micro:bit הדפס  _&#xD;es:micro:bit Imprimir _&#xD;ca:micro:bit Escriu _&#xD;fi:micro:bit Näytä teksti _&#xD;sv:micro:bit Visa text _&#xD;</translations><inputs><input type="%txt">Hello</input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>string</l></list><l>////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;// Encode any special characters in the URL&#xD;string = encodeURIComponent(string);&#xD;&#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.printObj === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.printObj = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        printString: function(string) {&#xD;            function callback() {&#xD;                if (window.birdbrain.printObj.stringToPrint === string) {&#xD;                    delete window.birdbrain.printObj.stringToPrint;&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.printObj.printString(window.birdbrain.printObj.stringToPrint);&#xD;                }&#xD;            }&#xD;            /*&#xD;            var report = {&#xD;                message:"L".charCodeAt(0),&#xD;                port: port.toString().charCodeAt(0),&#xD;                intensity: intensity&#xD;            };&#xD;            chrome.runtime.sendMessage(hummingbirdAppID, report, callback);&#xD;            */&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var printURL = "http://127.0.0.1:30061/hummingbird/out/print/" + string;&#xD;            xhr.open("GET", printURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);&#xD;&#xD;        }&#xD;    }&#xD;}&#xD;&#xD;//TODO Turn &apos;/&apos; chars into % &#xD;&#xD;if (window.birdbrain.printObj.stringToPrint === undefined) {&#xD;  window.birdbrain.printObj.printString(string);&#xD;}&#xD;&#xD;window.birdbrain.printObj.stringToPrint = string;</l></block><list><block var="string"/></list></block><block s="doWait"><l>0</l></block></script><scripts><script x="310.9999990000001" y="47"><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/print/</l><block var="string"/></list></block></block></block></script><script x="335" y="1024.8333343333334"><block var="intensity"/></script></scripts></block-definition><block-definition s="micro:bit Display $nl %&apos;r1c1&apos; %&apos;r1c2&apos; %&apos;r1c3&apos; %&apos;r1c4&apos; %&apos;r1c5&apos; $nl %&apos;r2c1&apos; %&apos;r2c2&apos; %&apos;r2c3&apos; %&apos;r2c4&apos; %&apos;r2c5&apos; $nl %&apos;r3c1&apos; %&apos;r3c2&apos; %&apos;r3c3&apos; %&apos;r3c4&apos; %&apos;r3c5&apos; $nl %&apos;r4c1&apos; %&apos;r4c2&apos; %&apos;r4c3&apos; %&apos;r4c4&apos; %&apos;r4c5&apos; $nl %&apos;r5c1&apos; %&apos;r5c2&apos; %&apos;r5c3&apos; %&apos;r5c4&apos; %&apos;r5c5&apos;" type="command" category="looks"><header></header><code></code><translations>ko:micro:bit 보이기 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;de:micro:bit LED Anzeige _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;pt:micro:bit Visor _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;fr:micro:bit Display _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;nl:micro:bit Scherm _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;zh_CN:micro:bit 显示 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;zh_TW:micro:bit 顯示 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;ar:micro:bit عرض _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;dk:micro:bit Display _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;he:micro:bit מסך _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;es:micro:bit Monitor _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;ca:micro:bit Pantalla _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;fi:micro:bit Näytä _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;sv:micro:bit Skärm _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _&#xD;</translations><inputs><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input><input type="%b">false</input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>r1c1, r1c2, r1c3, r1c4, r1c5, r2c1, r2c2, r2c3, r2c4, r2c5, r3c1, r3c2, r3c3, r3c4, r3c5, r4c1, r4c2, r4c3, r4c4, r4c5, r5c1, r5c2, r5c3, r5c4, r5c5 </l></list><l>////////////////////////////////////////////////////////////////////////////////&#xD;// In order to avoid sending more messages than the app can handle, whenever we&#xD;// send a message we also save it in a persistent global variable. When the&#xD;// message is processed in the app, the callback checks if the global variable&#xD;// still matches what it was changed to. If it was, it deletes the global&#xD;// variable. Otherwise the message is resent with new data.&#xD;//&#xD;// When this block is called it checks if the global value has been set. If it&#xD;// has, it sends a message. Otherwise it just updates the value and lets the&#xD;// callback handle it.&#xD;&#xD;// Create url representation from inputs&#xD;var symbolString =  r1c1 + "\/"+ r1c2 + "\/"+ r1c3 + "\/"+ r1c4 + "\/"+ r1c5 + "\/" +&#xD;                    r2c1 + "\/"+ r2c2 + "\/"+ r2c3 + "\/"+ r2c4 + "\/"+ r2c5 + "\/" +&#xD;                    r3c1 + "\/"+ r3c2 + "\/"+ r3c3 + "\/"+ r3c4 + "\/"+ r3c5 + "\/" +&#xD;                    r4c1 + "\/"+ r4c2 + "\/"+ r4c3 + "\/"+ r4c4 + "\/"+ r4c5 + "\/" +&#xD;                    r5c1 + "\/"+ r5c2 + "\/"+ r5c3 + "\/"+ r5c4 + "\/"+ r5c5 ;&#xD;&#xD;//r1c1, r1c2, r1c3, r1c4, r1c5, r2c1, r2c2, r2c3, r2c4, r2c5, r3c1, r3c2, r3c3, r3c4, r3c5, r4c1, r4c2, r4c3, r4c4, r4c5, r5c1, r5c2, r5c3, r5c4, r5c5 &#xD;&#xD;// We can&apos;t run code beforehand to define values so we must check each block&#xD;// call if they are set.&#xD;if (window.birdbrain === undefined || window.birdbrain.symbolObj === undefined) {&#xD;    window.birdbrain = window.birdbrain || {};&#xD;    window.birdbrain.symbolObj = {&#xD;        // By attaching this function to a global variable, it is only&#xD;        // defined once instead of every time this block is called, improving&#xD;        // performance significantly.&#xD;        printSymbol: function(symbol) {&#xD;            function callback() {&#xD;                if (window.birdbrain.symbolObj.symbolToPrint === symbol) {  // Check if arrays are equal&#xD;                    delete window.birdbrain.symbolObj.symbolToPrint;&#xD;                }&#xD;                else {&#xD;                    window.birdbrain.symbolObj.printSymbol(window.birdbrain.symbolObj.symbolToPrint);&#xD;                }&#xD;            }&#xD;&#xD;            //Create a new XMLHttpRequest object&#xD;            var xhr = new XMLHttpRequest();&#xD;            var symbolURL = "http://127.0.0.1:30061/hummingbird/out/symbol/A/" + symbol;&#xD;            xhr.open("GET", symbolURL, true);&#xD;            xhr.onload = function (e) {&#xD;              if (xhr.readyState === 4) {&#xD;                if (xhr.status === 200) {&#xD;                  callback();&#xD;                } else {&#xD;                  console.error(xhr.statusText);&#xD;                }&#xD;              }&#xD;            };&#xD;            xhr.onerror = function (e) {&#xD;              console.error(xhr.statusText);&#xD;            };&#xD;            xhr.send(null);&#xD;&#xD;        }&#xD;    }&#xD;}&#xD;&#xD;if (window.birdbrain.symbolObj.symbolToPrint === undefined) {&#xD;  window.birdbrain.symbolObj.printSymbol(symbolString);&#xD;}&#xD;&#xD;window.birdbrain.symbolObj.symbolToPrint = symbolString;&#xD;&#xD;&#xD;</l></block><list><block var="r1c1"/><block var="r1c2"/><block var="r1c3"/><block var="r1c4"/><block var="r1c5"/><block var="r2c1"/><block var="r2c2"/><block var="r2c3"/><block var="r2c4"/><block var="r2c5"/><block var="r3c1"/><block var="r3c2"/><block var="r3c3"/><block var="r3c4"/><block var="r3c5"/><block var="r4c1"/><block var="r4c2"/><block var="r4c3"/><block var="r4c4"/><block var="r4c5"/><block var="r5c1"/><block var="r5c2"/><block var="r5c3"/><block var="r5c4"/><block var="r5c5"/></list></block><block s="doWait"><l></l></block></script><scripts><script x="731" y="16"><block s="doReport"><block s="reportURL"><block s="reportJoinWords"><list><l>http://127.0.0.1:30061/hummingbird/out/symbol/A/</l><block var="11"/><l>/</l><block var="12"/><l>/</l><block var="r1c3"/><l>/</l><block var="r1c4"/><l>/</l><block var="r1c5"/><l>/</l><block var="r2c1"/><l>/</l><block var="r2c2"/><l>/</l><block var="r2c3"/><l>/</l><block var="r2c4"/><l>/</l><block var="25"/><l>/</l><block var="31"/><l>/</l><block var="r3c2"/><l>/</l><block var="33"/><l>/</l><block var="34"/><l>/</l><block var="35"/><l>/</l><block var="41"/><l>/</l><block var="42"/><l>/</l><block var="43"/><l>/</l><block var="44"/><l>/</l><block var="45"/><l>/</l><block var="51"/><l>/</l><block var="52"/><l>/</l><block var="53"/><l>/</l><block var="54"/><l>/</l><block var="55"/></list></block></block></block></script></scripts></block-definition></blocks>